<?php 
	namespace Home\Model;
	use Think\Model;
	class UserModel extends Model{
		    // 是否批处理验证
    	protected $patchValidate    =   true;
		protected $_validate=array(
			// array(字段，规则，错误提示，验证条件，附加规则，验证时间 后三个默认值可以不写)
			//1用户名验证 必须填写
			array('username','require','用户名必须填写'),
			array('username','','帐号名称已经存在！',0,'unique',1),
			array('password','require','密码必须填写'),
			array('password2','require','密码必须一樣'),
			array('password2','password','兩次密碼要移植',0,'confirm'),
			array('user_email','email','請填寫正確郵箱格式'),
			array('user_tel','/^1[345678]{1}\d{9}$/ ','手機號錯誤'),
			array('user_qq','5,12','QQ必須時數字',0,'length'),
			array('user_xueli','2,5','學歷選一個',0,'between'),
			array('user_hobby','check_hobby','2個以上',1,'callback'),

			); 
		public	function check_hobby($qw){
			if(count($qw)<2){
				return false;
			}
			return true;
		}
		public function checkPwd(){
			$count=array('username' => $_POST['username']);
			$a = $this->where($count)->find();
			if($a['password']=$_POST['password']){
				return $a;
			}else{
				return false;
			}
		}
	}


 ?>